//
//  H_NavigationController.m
//  Honey
//
//  Created by 贾亚涵 on 16/3/17.
//  Copyright © 2016年 贾亚涵. All rights reserved.
//

#import "H_NavigationController.h"

@interface H_NavigationController ()

@end

@implementation H_NavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    
    
    
}

-(void)initNavBar:(UIViewController *)vc
{
    //改变Nav的颜色
    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:246/255.0 green:157/255.0 blue:182/255.0 alpha:1]];
    
    //修改Nav上字体的颜色
    [[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName, nil]];
    
    //压栈时判断如果是二级界面就把tabBar隐藏
    if (self.viewControllers.count > 0)
    {
        vc.hidesBottomBarWhenPushed = YES;
        
        //二级页面加个返回箭头
        vc.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"tl_photo_slide_back.png"] style:UIBarButtonItemStylePlain target:self action:@selector(backBtn:)];
        
        vc.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];
    }
    
    
}

-(void)backBtn:(id)sender
{
    //出栈
    [self popViewControllerAnimated:YES];
}


//压栈方法
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    //压栈之前调用方法
    [self initNavBar:viewController];
    
    //后压栈
    [super pushViewController:viewController animated:YES];
}
@end
